package timbap.visualizer.api.plugin.container;

import timbap.visualizer.api.context.messaging.TimeCodeListener;
import timbap.visualizer.api.plugin.Plugin;

/**
 * The <code>AbstractRootPlugin</code> provides a common base
 * implementation for all plugins that can serve as the
 * root of the plugin tree.
 *
 * @author  Andreas Pabst
 * @see     timbap.visualizer.api.plugin.container.RootPlugin
 * @see     timbap.visualizer.api.plugin.container.AbstractGlobalPluginFork
 */
public abstract class AbstractRootPlugin extends AbstractGlobalPluginFork implements RootPlugin {

    private TimeCodeListener timeCodeListener;

    public void setTimeCodeListener(TimeCodeListener pTimeCodeListener) {
        timeCodeListener = pTimeCodeListener;
    }

    public TimeCodeListener getTimeCodeListener() {
        return timeCodeListener;
    }

    @Override
    public void addPlugin(Plugin pPlugin) {
        super.addPlugin(pPlugin);
        if (pPlugin instanceof TimeCodeListener) {
            setTimeCodeListener((TimeCodeListener)pPlugin);
        }
    }

}
